<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="824.41">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
    p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
    p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
    p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
    p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #bf0000}
    p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
    p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
    p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0000bf; min-height: 12.0px}
    p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0000bf}
    p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
    span.s1 {color: #0000bf}
    span.s2 {color: #000000}
    span.s3 {color: #007300}
    span.s4 {color: #606060}
    span.Apple-tab-span {white-space:pre}
  </style>
</head>
<body>
<p class="p1">//SLUGens released under the GNU GPL as extensions for SuperCollider 3, by Nick Collins, http://www.informatics.sussex.ac.uk/users/nc81/</p>
<p class="p2"><b></b><br></p>
<p class="p3"><b>FitzHughNagumo<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>Neuron Firing Model Oscillator</b></p>
<p class="p2"><b></b><br></p>
<p class="p4"><b>FitzHughNagumo.ar(reset, rateu, ratew, b0, b1, initu, initw, mul, add)</b></p>
<p class="p5"><br></p>
<p class="p4">Naive Euler ODE solver implementation of the FitzHugh-Nagumo neuronal 2-dimensional model for oscillatory firing. <span class="Apple-converted-space"> </span></p>
<p class="p5"><br></p>
<p class="p4">du/dt= rateu*(u-0.3333*u^3 - w)</p>
<p class="p4">dw/dt= ratew*(b0+b1*u - w)</p>
<p class="p5"><br></p>
<p class="p4">All inputs can have .kr rate UGens plugged in.</p>
<p class="p5"><br></p>
<p class="p4"><b>reset</b>- input</p>
<p class="p4"><b>rateu</b>- update rate for u</p>
<p class="p4"><b>ratew</b>- update rate for w<span class="Apple-converted-space"> </span></p>
<p class="p4"><b>b0</b>- equation constant</p>
<p class="p4"><b>b1</b>- equation constant</p>
<p class="p4"><b>initu</b>- reset value for u</p>
<p class="p4"><b>initw</b>- reset value for w</p>
<p class="p5"><br></p>
<p class="p6">//Can be very noisy, high pitched and aliases badly- ie great fun, but watch out for your ears, filter, try out odd param settings. I've turned all the amplitudes down in the following</p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p1">//defaults, high pitched! WARNING</p>
<p class="p8">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.05*<span class="s1">FitzHughNagumo</span>.ar(0,0.01,0.01,1,1),0.0))}.play</p>
<p class="p7"><br></p>
<p class="p1">//updates too fast, nice noise</p>
<p class="p8">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.02*<span class="s1">FitzHughNagumo</span>.ar(0,1,1,1,1),0.0))}.play</p>
<p class="p7"><br></p>
<p class="p1">//modulate constants to mess with noise</p>
<p class="p8">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.01*<span class="s1">FitzHughNagumo</span>.ar(0,1,1,<span class="s1">LFNoise0</span>.kr(1,0.48,0.5),<span class="s1">LFNoise0</span>.kr(1,0.9,1)),0.0))}.play</p>
<p class="p7"><br></p>
<p class="p1">//retrigger</p>
<p class="p8">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.1*<span class="s1">FitzHughNagumo</span>.ar(<span class="s1">Impulse</span>.kr(10),0.0001,0.001,1,0.000001,<span class="s1">LFNoise0</span>.kr(10),<span class="s1">LFNoise0</span>.kr(10)),0.0))}.play</p>
<p class="p7"><br></p>
<p class="p1">//more retriggering with mouse exploration<span class="s2"><span class="Apple-converted-space"> </span></span></p>
<p class="p8">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.05*<span class="s1">FitzHughNagumo</span>.ar(<span class="s1">Impulse</span>.kr(10),<span class="s1">MouseX</span>.kr(0.0001,0.1,<span class="s3">'exponential'</span>),<span class="s1">MouseY</span>.kr(0.0001,0.1,<span class="s3">'exponential'</span>),0.5,0.1,<span class="s1">LFNoise0</span>.kr(10,0.3),<span class="s1">LFNoise0</span>.kr(10,0.2)),0.0))}.play</p>
<p class="p7"><br></p>
<p class="p1">//right of the screen is most amusing</p>
<p class="p8">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(0.1*<span class="s1">FitzHughNagumo</span>.ar(<span class="s1">Impulse</span>.kr(100),<span class="s1">MouseX</span>.kr(0.0001,1,<span class="s3">'exponential'</span>),<span class="s1">MouseY</span>.kr(0.0001,1,<span class="s3">'exponential'</span>),0.5,0.1,<span class="s1">SinOsc</span>.kr(10,0,0.3),<span class="s1">SinOsc</span>.kr(10,0,0.8)),0.0))}.play</p>
<p class="p7"><br></p>
<p class="p1">//explore</p>
<p class="p1">(</p>
<p class="p8">{<span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar(</p>
<p class="p9"><br></p>
<p class="p10">CombN.ar(</p>
<p class="p8"><span class="s1">Resonz.ar(FitzHughNagumo</span>.ar(<span class="s1">Impulse</span>.kr(<span class="s1">LFNoise1</span>.kr(1,10,50)),<span class="s1">MouseX</span>.kr(0.0001,100,<span class="s3">'exponential'</span>),<span class="s1">MouseY</span>.kr(0.0001,1,<span class="s3">'exponential'</span>),<span class="s1">MouseY</span>.kr(0.1,3),<span class="s1">MouseX</span>.kr(0.1,3),<span class="s1">SinOsc</span>.kr(20,0,0.7),<span class="s1">SinOsc</span>.kr(21,0,0.8)),LFNoise1.kr(LFNoise1.kr(0.2,0.05,0.07),400,600),0.1),</p>
<p class="p8">0.05,0.05,2</p>
<p class="p8">)</p>
<p class="p8">,0.0))}.play</p>
<p class="p8">)</p>
<p class="p7"><br></p>
<p class="p1">//surprise! (wait for it)</p>
<p class="p8">(</p>
<p class="p10">SynthDef<span class="s2">(</span><span class="s4">"FHN-surprise"</span><span class="s2">,{</span>Out<span class="s2">.ar(0,</span>Pan2<span class="s2">.ar(</span></p>
<p class="p7"><br></p>
<p class="p8"><span class="s1">CombN</span>.ar(<span class="s1">RLPF</span>.ar(<span class="s1">FitzHughNagumo</span>.ar(0,0.00001,0.00001, mul:0.1),1000,0.01),0.1,0.1,10)</p>
<p class="p8">,0.0))</p>
<p class="p8">}).play</p>
<p class="p8">)</p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p1">//controlled surprise</p>
<p class="p8">(</p>
<p class="p10">SynthDef<span class="s2">(</span><span class="s4">"FHN-surprise"</span><span class="s2">,{</span>Out<span class="s2">.ar(0,</span>Pan2<span class="s2">.ar(</span></p>
<p class="p7"><br></p>
<p class="p8"><span class="s1">CombN</span>.ar(<span class="s1">RLPF</span>.ar(<span class="s1">FitzHughNagumo</span>.ar(0,0.00001,<span class="s1">MouseY</span>.kr(0.00001,1,<span class="s3">'exponential'</span>),<span class="s1">1</span>, mul:0.1),1000,0.01),0.1,0.1,10)</p>
<p class="p8">,0.0))</p>
<p class="p8">}).play</p>
<p class="p8">)</p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p1">//feedback pair</p>
<p class="p8">(</p>
<p class="p11"><span class="s1">SynthDef</span><span class="s2">(</span>"FHN-surprise"<span class="s2">,{</span></p>
<p class="p8"><span class="s1">var</span> fn1, fn2, retrigger;</p>
<p class="p7"><br></p>
<p class="p8">retrigger= Impulse.kr(15);</p>
<p class="p7"><br></p>
<p class="p8">fn1= <span class="s1">MouseX</span>.kr(0.0,1.0)*<span class="s1">FitzHughNagumo</span>.ar(retrigger,0.001,0.001,<span class="s1">LocalIn</span>.ar(1),1);</p>
<p class="p8">fn2= <span class="s1">MouseY</span>.kr(0.0,1.0)*<span class="s1">FitzHughNagumo</span>.ar(retrigger,0.001,0.001,fn1,1);</p>
<p class="p7"><br></p>
<p class="p8"><span class="s1">LocalOut</span>.ar(fn2);</p>
<p class="p7"><br></p>
<p class="p8"><span class="s1">Out</span>.ar(0,<span class="s1">Pan2</span>.ar((fn1+fn2),0.0))</p>
<p class="p8">}).play</p>
<p class="p8">)</p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p7"><br></p>
</body>
</html>
